Ccay.Module.define("Ccay.demo.pageswitch.PageSwitch",function(page,$S){
	
	page.ready = function(){
		//tab初始化
		$S("#pageTab").ccayTab();
		//页面注册
		Ccay.Page.register("Ccay.demo.pageswitch.SwitchView","ccay/example/ui/pageswitch/switchView.html");
	}
	//以tab 方式打开
	page.openOfTab = function(mname,bool){
		//debugger;
		var obj = {tab:'#pageTab'} , 
			count = $("#pageTab").manager().getItemCount(),
			str = "TAB方式({0})" ,
			defaultIdTab = $("#pageTab li[tabid='_addtabitem_default']");
		if(bool){
			obj.permitsMany = true;
			str = str.formatValue(defaultIdTab.length ? count - 5 : count - 4);
		}
		str = str.formatValue("单个")
		//bool && ( obj.permitsMany = true );
		Ccay.Common.openPage(str,"Ccay.demo.pageswitch.SwitchView",obj
		,function(){
			Ccay.demo.pageswitch.SwitchView.init($S(mname).val());
		});
	}
	
	//以弹出框方式打开
	page.openOfPopup = function(mname){
		Ccay.Common.openPage("弹出框方式","Ccay.demo.pageswitch.SwitchView",
			{
				height:410,
				width:680,
				buttons:[
					{
						text:"ccay.common.button.cancel",
			         	type:"imgBtn",
				      	icon:"cancel",
				      	cls:"ccay-icon",
			         	onClick:function(){
			         		Ccay.demo.pageswitch.SwitchView.closeDialog();
			         	}
					}
				]
			},function(){
				Ccay.demo.pageswitch.SwitchView.init($S(mname).val(),1);
			}
		);
	}
	page.closeTab = function(){
		$('#pageTab').ccayTabRemoveItem();
	}
})